<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 600px;
            height: 600px;
            background: palegoldenrod;
            background: url(../akali.jpg) no-repeat center center;
            background-size: 600px 600px !important;
        }
        .btn1,.btn2{
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            margin-left: 130px;
            margin-top: 200px;
        }
        .btn3{
            background: papayawhip;
        }
        .box2{
            background: url(../nvq.jpg) no-repeat center center;
        }
    </style>
</head>
<body>
    <div>
        <button class="btn1">按钮1</button>
        <button class="btn1">按钮2</button>
    </div>
    <script>
        var btn = document.querySelectorAll('.btn1')
        var box = document.querySelector('div')
        for(let i=0;i<btn.length;i++){
            btn[i].onclick = function () {
                for(var j=0;j<btn.length;j++){
                    btn[j].classList.remove('btn3')
                }
                this.classList.add('btn3')
                // console.log(box.classList)
                if(box.classList == 'box2'){
                    box.classList.remove('box2')
                }else{
                    box.classList.add('box2')
                }
                
            }
        }
        
    </script>
</body>
</html>